package com.wamke.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wamke.mapper.DeptMapper;
import com.wamke.pojo.Dept;
import com.wamke.pojo.DeptDTO;
import com.wamke.pojo.PageBean;
import com.wamke.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: wanke
 * @ClassName DeptServiceImpl
 * @author: WXK
 * @create: 2023-10-21 14:57
 **/
@Service
@Slf4j
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;

    //条件查询
    public PageBean selectCondition(DeptDTO deptDTO) {
        PageHelper.startPage(deptDTO.getPage(),deptDTO.getPageSize());
        Page<Dept> page = deptMapper.selectCondition(deptDTO);
         return new PageBean(page.getTotal(),page.getResult());
    }

    //根据id 删除
    public void deleteById(String id) {

        deptMapper.delete(id);
    }
}
